Skip to content

Conversation

@garydgregory
Copy link
Member

@garydgregory garydgregory commented Jan 14, 2026

Make NioSession.getChannel() public, as I am currently using reflection to access this method.

This is in the context of a complex (proprietary) framework I have at work.

CC @tomaswolf

@garydgregory garydgregory marked this pull request as draft January 14, 2026 15:01
@garydgregory garydgregory changed the base branch from trunk to 2.2.X January 14, 2026 15:01
@garydgregory garydgregory marked this pull request as ready for review January 14, 2026 15:02
@elecharny
Copy link
Contributor

I'll deal with that asap.

@elecharny elecharny merged commit 9e45469 into apache:2.2.X Jan 18, 2026
@elecharny
Copy link
Contributor

Just a question: what's the rational for accessing this protected field? The risk being that the channel is closed outside of the logical flow

@garydgregory
Copy link
Member Author

Once I get hold of it, I can check if it is a SocketChannel and do further introspection on it.

For some of our tests, I can change the state of the SocketChannel and make ensure our upstack code can recover from various unexpected and bad states.

@elecharny
Copy link
Contributor

elecharny commented Jan 18, 2026

OTOH, if you know you are dealing with a NioSocketSession, you know for sure it's a SocketChannel.

Sure there are missing functions that would give you back the underlying channel status (like isChannnelConnected() or such), but well, I get your requirement, and it's simpler to make the function public.

We can debate it if we should give access to the channel state instead of giving full access to the full channel, because that would allow any application to write/read/shutdown it, which IMHO opens the door a bit wide.

Just let me know what you think of it, to see if there is some means to do that and have your app happy at the same time.

In the mean time, patch applied.

@garydgregory
Copy link
Member Author

I don't think we need to expand the public API footprint beyond that.
I need the actual socket channe object for one kind of test where we forcibly reset the socket channel state without actually closing it. All connections live a Commons Pool pool.

@garydgregory garydgregory deleted the 2_2_x/NioSession_getChannel_public branch January 19, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants